import {defineConfig} from 'vitepress'

import mathjax3 from 'markdown-it-mathjax3'
import {customElements} from "./constant";
// 导入主题的配置
import {blogTheme} from './blog-theme'

import {pagefindPlugin, chineseSearchOptimize} from 'vitepress-plugin-pagefind'

import {srcDir, outDir, cacheDir} from "./constant";

const pluginPageFind = pagefindPlugin({
    customSearchQuery: chineseSearchOptimize,
    btnPlaceholder: '搜索',
    placeholder: '搜索文档',
    emptyText: '空空如也',
    heading: '共: {{searchResult}} 条结果',
    indexingCommand: 'npx pagefind --site dist --exclude-selectors "div.aside, a.header-anchor"'
});

export default defineConfig({
    markdown: {
        math: true
    },
    vue: {
        template: {
            compilerOptions: {
                isCustomElement: (tag) => customElements.includes(tag),
            }
        }
    },
    vite: {
        plugins: [pluginPageFind]
    },
    srcDir,
    outDir,
    cacheDir,
    // 继承博客主题(@sugarat/theme)
    extends: blogTheme,
    lang: 'zh-cn',
    title: 'FatGod Blog',
    description: '小胖神的博客网站',
    lastUpdated: true,
    cleanUrls: true,
    // 详见：https://vitepress.dev/zh/reference/site-config#head
    head: [
        // 配置网站的图标（显示在浏览器的 tab 上）
        ['link', {rel: 'icon', href: '/favicon.ico'}]
    ],
    themeConfig: {
        // 展示 2,3 级标题在目录中
        outline: {
            level: [2, 3],
            label: '目录'
        },
        // 默认文案修改
        returnToTopLabel: '回到顶部',
        sidebarMenuLabel: '相关文章',
        lastUpdatedText: '上次更新于',

        // 设置logo
        logo: '/logo.png',
        // editLink: {
        //   pattern:
        //     'https://github.com/ATQQ/sugar-blog/tree/master/packages/blogpress/:path',
        //   text: '去 GitHub 上编辑内容'
        // },
        nav: [
            {text: '首页', link: '/'},
            {
                text: '计算机基础',
                items: [
                    {
                        text: '算法合集', items: [
                            {
                                text: '二分查找',
                                link: '/doc/computer-basics/algo-collection/binary-search/escape-the-spreading-fire'
                            },
                            {
                                text: '动态规划',
                                link: '/doc/computer-basics/algo-collection/dp/house-robber'
                            },
                            {
                                text: '网格图',
                                link: '/doc/computer-basics/algo-collection/grid/making-a-large-island'
                            },
                        ]
                    }
                ]
            },
            {
                text: 'Java',
                items: [
                    {text: 'Java虚拟机', link: '/doc/java/jvm/class-loading'},
                    {text: 'MyBatis',link: '/doc/java/mybatis/mybatis-quick-start'}
                ]
            },
            {
                text: '中间件',
                items: [
                    {text: 'MySQL', link: '/doc/middleware/mysql/mvcc'}
                ]
            },
            {
                text: 'Web前端',
                items: [
                    {
                        text: 'CSS', items: [
                            {text: '常用属性', link: '/doc/web/css/properties/background'},
                            {text: '布局', link: '/doc/web/css/layout/position'},
                            {text: '核心概念', link: '/doc/web/css/core/stacking-context'},
                        ]
                    },
                    {text: 'JS', link: '/web/js'}
                ]
            },
        ],
        socialLinks: [
            {
                icon: 'github',
                link: 'https://github.com/ATQQ/sugar-blog/tree/master/packages/theme'
            }
        ],
    }
})
